// =====================================================================
// <copyright file="MemoryLog.cs" author="David R. Guindo">
// 	Copyright (C) 2014. All rights reserved.
// </copyright>
// =====================================================================
// This code is released under the terms of the Apache 2.0 license, 
// http://apache.org/licenses/LICENSE-2.0.html
// =====================================================================

namespace AppBlocks
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// </summary>
    public class MemoryLog : ILog
    {
        public MemoryLog()
        {
            this.LogMemory = new Dictionary<string, object>();
        }

        /// <summary>
        ///     Gets or sets the memory log.
        /// </summary>
        /// <value>
        ///     The memory log.
        /// </value>
        public Dictionary<string, object> LogMemory { get; set; }

        /// <summary>
        ///     Log debug message.
        /// </summary>
        /// <param name="message">The debug message to write.</param>
        /// <param name="args">The arguments to replace message values.</param>
        public void LogDebug(string message, params object[] args)
        {
            this.LogMemory.Add(string.Format(message, args), null);
        }

        /// <summary>
        ///     Log error message.
        /// </summary>
        /// <param name="message">The error message to write.</param>
        /// <param name="args">The arguments to replace message values.</param>
        public void LogError(string message, params object[] args)
        {
            this.LogMemory.Add(string.Format(message, args), null);
        }

        /// <summary>
        ///     Log error message.
        /// </summary>
        /// <param name="exception">The exception associated with this error.</param>
        /// <param name="message">The error message to write.</param>
        /// <param name="args">The arguments to replace message values.</param>
        public void LogError(Exception exception, string message, params object[] args)
        {
            this.LogMemory.Add(string.Format(message, args), exception);
        }

        /// <summary>
        ///     Log fatal message.
        /// </summary>
        /// <param name="message">The warning message to write.</param>
        /// <param name="args">The arguments to replace message values.</param>
        public void LogFatal(string message, params object[] args)
        {
            this.LogMemory.Add(string.Format(message, args), null);
        }

        /// <summary>
        ///     Log message information .
        /// </summary>
        /// <param name="message">The information message to write.</param>
        /// <param name="args">The arguments to replace message values.</param>
        public void LogInfo(string message, params object[] args)
        {
            this.LogMemory.Add(string.Format(message, args), null);
        }

        /// <summary>
        ///     Log warning message.
        /// </summary>
        /// <param name="message">The warning message to write.</param>
        /// <param name="args">The arguments to repllace message values.</param>
        public void LogWarning(string message, params object[] args)
        {
            this.LogMemory.Add(string.Format(message, args), null);
        }
    }
}